<?php

namespace App\Admin\Controllers\Bargain;

use App\Admin\Repositories\Bargain\CmcPromotionBargainLaunch;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class CmcPromotionBargainLaunchController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new CmcPromotionBargainLaunch(), function (Grid $grid) {
            $grid->column('launch_id')->sortable();
            $grid->column('bargain_id');
            $grid->column('sku_id');
            $grid->column('goods_id');
            $grid->column('sku_name');
            $grid->column('sku_image');
            $grid->column('price');
            $grid->column('buy_type');
            $grid->column('bargain_type');
            $grid->column('need_num');
            $grid->column('curr_num');
            $grid->column('start_time');
            $grid->column('end_time');
            $grid->column('status');
            $grid->column('member_id');
            $grid->column('nickname');
            $grid->column('headimg');
            $grid->column('is_fenxiao');
            $grid->column('order_id');
            $grid->column('first_bargain_price');
            $grid->column('curr_price');
            $grid->column('is_own');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('launch_id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new CmcPromotionBargainLaunch(), function (Show $show) {
            $show->field('launch_id');
            $show->field('bargain_id');
            $show->field('sku_id');
            $show->field('goods_id');
            $show->field('sku_name');
            $show->field('sku_image');
            $show->field('price');
            $show->field('buy_type');
            $show->field('bargain_type');
            $show->field('need_num');
            $show->field('curr_num');
            $show->field('start_time');
            $show->field('end_time');
            $show->field('status');
            $show->field('member_id');
            $show->field('nickname');
            $show->field('headimg');
            $show->field('is_fenxiao');
            $show->field('order_id');
            $show->field('first_bargain_price');
            $show->field('curr_price');
            $show->field('is_own');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new CmcPromotionBargainLaunch(), function (Form $form) {
            $form->display('launch_id');
            $form->text('bargain_id');
            $form->text('sku_id');
            $form->text('goods_id');
            $form->text('sku_name');
            $form->text('sku_image');
            $form->text('price');
            $form->text('buy_type');
            $form->text('bargain_type');
            $form->text('need_num');
            $form->text('curr_num');
            $form->text('start_time');
            $form->text('end_time');
            $form->text('status');
            $form->text('member_id');
            $form->text('nickname');
            $form->text('headimg');
            $form->text('is_fenxiao');
            $form->text('order_id');
            $form->text('first_bargain_price');
            $form->text('curr_price');
            $form->text('is_own');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
